<?php
$this->pageTitle="Báo cáo Doanh thu";
$this->beginWidget('webroot.widgets.iPortlet', array('title'=>Yii::t('main','Báo cáo doanh thu theo ngày')));
?>
<form action="" method="get">
<input type="hidden" name="r" value="bill/report/index">
<table>
<tr>
	<td width="200">
		<?php 
		$this->widget('ext.daterangepicker.input',array(
				'name'=>'datetime',
				'value'=>isset($_GET['datetime'])?$_GET['datetime']:'',
		));
		?>
	</td>
	<td>
		<button type="submit" class="btn btn-primary">Xem</button>
	</td>
</tr>
</table>

<?php if(!empty($data)):
$i=1;
?>
<style>
table{
	width: 100%;
	border-color: #ddd;
}
table tr th{
	background:#ccc;
}
table tr th, table tr td{
	padding: 5px;
}
</style>
<div class="wrr-x-grid">
<div style="text-align: right;padding: 5px;">
<button type="submit" name="export" value="export" class="btn btn-primary">Export Excel</button>
</div>
<table class="items itable" border="1">
<tr>
	<th>STT</th>
	<th>Ngày gửi</th>
	<th>Khách hàng</th>
	<th>Người nhận</th>
	<th>Hãng CPN</th>
	<th>Air Bill</th>
	<th>Trọng lượng (gr)</th>
	<th>Tiền cước</th>
</tr>
<?php 
$totalFee = 0;
foreach ($data as $key => $value):
$totalFee +=$value['fee'];
?>
<tr>
	<td><?php echo $i;?></td>
	<td><?php echo $value['date'];?></td>
	<td><?php echo $value['customer_name'];?></td>
	<td><?php echo $value['receiver'];?></td>
	<td><?php echo $value['type'];?></td>
	<td><?php echo $value['air_bill'];?></td>
	<td><?php echo $value['product_weight'];?></td>
	<td><?php echo Common::priceFormat($value['fee']);?></td>
</tr>
<?php 
$i++;
endforeach;?>
</table>
<div style="text-align: right; padding: 10px;">
Tổng cước: <?php echo Common::priceFormat($totalFee);?>
</div>
</div>
<?php elseif($this->time!=''):?>
<div>Không có Bill nào.</div>
<?php endif;?>
</form>
<?php $this->endWidget();?>